package com.guoxue.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.guoxue.dao.IPublishLogsDao;
import com.guoxue.domain.PublishLogsVo;
@Repository
public class PublishLogsDaoImpl extends BaseDaoImpl<PublishLogsVo> implements IPublishLogsDao {

	@Override
	public List<PublishLogsVo> getPublishLogs() {
		return find("FROM PublishLogsVo p WHERE p.status <> 2");
	}

	@Override
	public void savePublishLogs(PublishLogsVo pub) {
		 saveOrUpdate(pub);
	}

	@Override
	public void deleteForStatus(int id) {
		executeHql("UPDATE PublishLogsVo p SET p.status=2 WHERE p.id=?", new Object[] {id});
	}

	@Override
	public void updateStatus(String versionCode) {
		executeHql("UPDATE PublishLogsVo p SET p.status=1 WHERE p.status=4");
		executeHql("UPDATE PublishLogsVo p SET p.status=4 WHERE p.versionCode=?",new Object[] {versionCode});
	}

	@Override
	public PublishLogsVo getPublishByStatus(String i) {
		return get("FROM PublishLogsVo p WHERE p.status=?", new Object[] {i});
	}

}
